package com.example.auth;

import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;

public class Demo {

    /**
     * java -jar your-app.jar -Djasypt.encryptor.password=my-secret-key
     *
     * @param args
     */
    public static void main(String[] args) {
        StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();

        // 设置加密密钥（非常重要！）
        encryptor.setAlgorithm("PBEWithMD5AndDES");
        encryptor.setPassword("my-secret-key");
        //PBEWithMD5AndDES

        // 加密字符串
        String originalPassword = "123456";
        String encryptedPassword = encryptor.encrypt(originalPassword);

        System.out.println("加密后的字符串: ENC(" + encryptedPassword + ")");

        // 解密验证
        String decrypted = encryptor.decrypt(encryptedPassword);
        System.out.println("解密验证: " + decrypted);
    }
}
